<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
<script>
    // ES5语法实现 获取对象指定的属性
    let book = {
        title: 'vue源码研究',
        author: 'jack',
        age: 50,
        year: 2022,
        price: '$9.99'
    }

    // function pick(obj) {
    //     let result = Object.create(null)
    //     for (let i = 1; i < arguments.length; i++) {
    //         result[arguments[i]] = obj[arguments[i]]
    //     }
    //     return result
    // }

    // 在ES6中使剩余参数解决, 由...每一个紧跟着的具名参数指定...keys
    // ...keys 解决了arguments问题
    function pick2(obj, ...keys) {
        console.log('obj:', obj)
        console.log('keys:', keys)
        let result = Object.create(null)
        for (let i = 0; i < keys.length; i++) {
            result[keys[i]] = obj[keys[i]]
        }
        return result
    }

    let data = pick2(book, 'author', 'year', 'price')
    console.log(data)
    console.log('===================================')

    function checkArgs(...args){
        console.log(args)
        console.log(arguments)
    }

    checkArgs('a','b','c')

    // 使用扩展运算符  将一个数组分割，并将各个项作为分离的参数传给函数
    let my = [1,5,3,2,6,7,2,3,4,5]
    console.log(Math.max(...my))
</script>
</body>

</html>
